import config from '../config'
import model from '../model/boss'
import CanvasAbstract from './canvasAbstract'

class Boss extends CanvasAbstract implements ICanvas {
  num(): number {
    return 0
  }
  model(): ModelConstructor {
    return model
  }

  // 这里的render方法在main.ts文件中执行了
  render(): void {
    this.createModels()
    super.renderModels()
  }

  createModels() {
    const pos = [
      {
        x: config.canvas.width / 2,
        y: config.canvas.height - config.model.height,
      },
    ]

    pos.forEach((position) => {
      const model = this.model() as ModelConstructor
      const instance = new model(position.x, position.y)
      this.models.push(instance)
    })
  }
}

export default new Boss('boss')
